var express = require("express");
var router = express.Router();
var mysql = require("mysql");
var DateUtil = require('../lib/utils/DateUtil');
var _ = require("underscore");

var connection = require('../lib/utils/DbconnectUtil');

router.get('/auditlist', function (req, res, next) {
    var queryAudit = 'select * from t_audit';
    connection().query(queryAudit, function (error, results) {
        if (error) {
            res.send({code : -1 , message: JSON.stringify(error)});
        } else {
            res.send({code :0 , data : results});
        }
    });
});

router.get('/tracklist', function (req, res, next) {
    var menuId = '23'; //活动公示信息;
    var queryContentSql = 'select ' +
        't_content.id id, ' +
        't_content.name name, ' +
        't_content.summary summary, ' +
        't_content.type type, ' +
        't_content.coverUrl coverUrl, ' +
        't_content.videoUrl videoUrl, ' +
        't_content.updateAt updateAt, ' +
        't_content.stick stick, ' +
        't_content.content content, ' +
        't_content.menu subMenuId ' +
        'from t_content ' +
        'where t_content.menu = ?  order by updateAt desc limit 0,15 ';;
    connection().query(queryContentSql,[menuId], function (error, results) {
        if (error) {
            res.send({code : -1 , message: JSON.stringify(error)});
        } else {
            res.send({code :0 , data : results});
        }
    });
});

module.exports = router;